package com.example.jsondemo.service.impl;

import com.example.jsondemo.dto.RuleDefinition;
import com.example.jsondemo.repository.RuleDefinitionRepository;
import com.example.jsondemo.service.RuleDefinitionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Keson
 * @version 1.0
 * @description: TODO 权限控制service的实现
 * @date 2021/9/15 11:32
 */
@Service
public class RuleDefinitionServiceImpl implements RuleDefinitionService {

    @Autowired
    private RuleDefinitionRepository ruleDefinitionRepository;

    @Override
    public List<RuleDefinition> getRules(String wildcardResourceContext, String roleId, String resourceContext, List<String> roleIds) {
        return ruleDefinitionRepository.findByResourceContextEqualsAndRoleIdEqualsOrResourceContextEqualsAndRoleIdIn
                (wildcardResourceContext, roleId, resourceContext, roleIds);
    }
}
